Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile time improvement: depend on subcrates #319

Merged
merged 5 commits into from
Nov 10, 2024

Conversation

aevyrie
Copy link
Contributor

@aevyrie aevyrie commented Nov 8, 2024

bevy_egui was causing compilation of our large projects to delay until bevy, and more critically, bevy_pbr were done compiling. bevy_pbr is extremely slow, and depends on bevy_render, which is also slow to compile. The result is compilation cannot parallelize well.

This change should be entirely idempotent for users, it simply switches dependencies to the bevy subcrates. The effect of this is that bevy_egui, and anything that depend on it, can now start compiling at the same time as bevy_pbr, this had a huge positive effect on compile times in our larger project, because many things depend on bevy_egui.

The only "gotcha" here is that I had to depend on encase manually, otherwise you end up needing to go through bevy's ShaderType derive, which falls over when bevy is not in scope.

Using --timings on the simple example, on an M3 Max:

Before
image

After
image

As expected, this has no impact on the compile time of examples, because bevy_pbr still dominates, but in real applications, you will usually have a bunch of crates depending on bevy_egui, which can now start compiling a whole 4 seconds earlier (and even more on slower machines).

@aevyrie aevyrie changed the title Switch to depending on subcrates Compile time improvement: depend on subcrates Nov 8, 2024
@aevyrie aevyrie force-pushed the depend-on-subcrates branch 2 times, most recently from 3df94e8 to 2397c46 Compare November 8, 2024 19:30
@aevyrie aevyrie force-pushed the depend-on-subcrates branch from 2397c46 to 89b8797 Compare November 8, 2024 20:38
@vladbat00
Copy link
Owner

This is great, thank you!

@vladbat00 vladbat00 merged commit c7638f0 into vladbat00:main Nov 10, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants